Introduce image and CSS CSP controls#6071
Introduce image and CSS CSP controls#6071Zhey-on wants to merge 1 commit intoBookStackApp:developmentfrom
Conversation
ssddanbrown
left a comment
There was a problem hiding this comment.
Thanks for offering this @Zhey-on,
Please can you remove the readme and dev/docs changes though. Information on something this specific isn't relevant for these areas. I'll document this CSP use in our docs site as part of the future release changes.
|
BookStack is now managed on Codeberg. As part of this change, we're closing all existing GitHub issues and pull requests. Any further discussion for this will now be done primarily on Codeberg. |
Summary
This PR introduces CSP controls for image and CSS sources.
In line with the issue intent, the defaults are kept relatively permissive to prevent breaking changes on existing instances, while still providing clear options to tighten policies where needed.
Changes
img-srcandstyle-srcdirectives to CSP handling.ALLOWED_IMAGE_SOURCESALLOWED_CSS_SOURCESSecurityHeaderTestfor:.env.example.completeentries and examplesWhy this approach
The implementation is intentionally conservative by default, especially compared to JS/iframe controls, so instances do not unexpectedly break after upgrade. At the same time, admins can now explicitly restrict allowed sources as part of their hardening process.
Testing
docker compose run --rm app php artisan test tests/SecurityHeaderTest.php --filter="style src|img src|csp"Closes #6033.